﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meraz.Core.Model;

namespace Meraz.Core.Repositories
{
    public class PosterRepository : EFRepositoryBase<Poster, int>, IPosterRepository
    {
        public PosterRepository() : base() { }
        public PosterRepository(Data.IMerazContext context) : base(context) { }

        public override Poster GetById(int id)
        {
            return context.Posters
                .Where(where1 => where1.ID == id)
                .FirstOrDefault();
        }
        public Poster GetByName(int postID, string name)
        {
            return context.Posters
                .Where(where1 => where1.PostID == postID && where1.Alias.Name == name)
                .FirstOrDefault();
        }
        public override void Add(Poster entity)
        {
            context.Posters.AddObject(entity);
        }

        public override void Delete(Poster entity)
        {
            context.Posters.DeleteObject(entity);
        }

        public override List<Poster> All()
        {
            return context.Posters.ToList();
        }
    }
}
